<template>
  <div>
    <el-table
      :data="list"
      style="width: 100%;margin-bottom: 20px;"
      row-key="id"
      border
      :tree-props="{children: 'children'}"
    >
      <el-table-column prop="id" label="用户编号" sortable width="180"></el-table-column>
      <el-table-column prop="username" label="用户名" sortable width="180"></el-table-column>
     <el-table-column prop="rolename" label="所属角色" sortable width="180"></el-table-column>
      
      <el-table-column label="状态">
        <template slot-scope="scope">
          <el-button type="primary" v-if="scope.row.status==1">启用</el-button>
          <el-button type="info" v-else>禁用</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="willEdit(scope.row.uid)">编辑</el-button>
          <el-button type="danger" @click="del(scope.row.uid)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- <el-pagination
    layout="prev, pager, next"
    :total="50"
    page-size>
  </el-pagination> -->
  </div>
</template>
<script>
import { reqmenudel, requserdelete } from "../../../request/api";
import { successAlert } from "../../../utils/alert";

export default {
  components: {},
  mounted() {},
  props: ["list"],
  data() {
    return {
      
    };
  },
  methods: {
    //点击编辑
    willEdit(uid) {
      this.$emit("edit",uid);
    },
    //点击删除
    del(uid) {
      this.$confirm("你确定要删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        //点了确定
        requserdelete({ uid: uid }).then((res) => {
            //弹成功
            successAlert(res.data.msg);
            //刷新页面
            this.$emit("init");
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除",
            });
          });
      });
    },
  },
};
</script>
<style lang="less" scoped>
</style>